package com.huang.aclservice.controller;


import com.huang.aclservice.entity.Permission;
import com.huang.aclservice.service.PermissionService;

import com.hunag.utils.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 权限 菜单管理
 * </p>
 *
 * @author testjava
 * @since 2020-01-12
 */
@RestController
@RequestMapping("/admin/acl/permission")
public class PermissionController {

    @Autowired
    private PermissionService permissionService;

    @ApiOperation("查询所有菜单并封装")
    @GetMapping("queryAllMenu")
    public R queryAllMenu(){
       List<Permission> list= permissionService.queryAllM();
       return R.ok().data("children",list);
    }

    @ApiOperation("递归删除菜单")
    @DeleteMapping("deleteMnue/{id}")
    public R deleteMnue(String id){
        permissionService.deleteMnue(id);
        return R.ok();
    }


    @ApiOperation("给角色分配菜单")
    @GetMapping("saveRolePermission")
    public R saveRolePermission(String roleId, String[] permissionId){
        permissionService.saveRolePermission(roleId,permissionId);
        return R.ok();
    }

}

